import { Component, OnInit } from '@angular/core';
// @ts-ignore
import {JsUtilsApi} from 'great-jsutils';

@Component({
  selector: 'app-md5',
  templateUrl: './md5.component.html',
  styleUrls: ['./md5.component.less']
})
export class Md5Component implements OnInit {

  file = {
    fileName: null,
    fileMd5: null,
  };

  constructor() { }

  ngOnInit() {
  }

  readFile(event: any) {
    const input = event.target;
    let file = input.files[0];
    this.file.fileName = file.name;
    JsUtilsApi.md5File(file).then(
      (md5)=>{
        this.file.fileMd5 = md5;
      },
      (error)=>{
        console.log(error);
      }
    );
  }

}
